<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<!-- bootstrap样式、主题、核心文档 -->
<link rel="stylesheet" href="libs/bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="libs/bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap-theme.min.css" />
<script type="text/javascript" src="libs/bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="libs/jquery/jquery.js"></script>
<style type="text/css">
	.jumbotron{
		height:400px;
	}
	.btn.btn-info{
		width:200px;
		font-size: 20px;
	}
	.inner{
		float:left;
		height:300px;
	}
	#inner2{
		background-color: white;
	}
	
	.container{
		margin-left: 0;
		margin-right: 0;
		width:100%;
	}
	p>span{
		display:inline-block;
		width:100px;
	}
</style>
</head>
<body>
<div class="jumbotron container">
		<div style="width:100%; text-align: center" class="inner container">
		<form class="form-inline">
		<p><span>用户名</span><input type="text" class="form-control"  placeholder="输入用户名" style="width:200px;" name="username">
		<span>真实姓名</span><input type="text" class="form-control"  placeholder="输入真实姓名" style="width:200px;" name="realname">
		</p>
		<p><span>身份证号</span><input type="text" class="form-control"  placeholder="输入身份证号" style="width:200px;" name="idnumber">
		<span>手机号</span><input type="text" class="form-control"  placeholder="输入手机号" style="width:200px;" name="phonenumber">
		</p>
		<p>
		<span>邮箱</span><input type="email" class="form-control"  placeholder="输入邮箱" style="width:200px;" name="email">
		<span>现居住地</span><input type="text" class="form-control"  placeholder="输入现居住地址" style="width:200px;" name="addr">
		</p>
		<p>
		<span>密&nbsp;&nbsp;码</span><input type="password" class="form-control"  placeholder="输入密码" style="width:200px;" name="password">
		<span>确认密码</span><input type="password" class="form-control"  placeholder="确认密码" style="width:200px;">
		
		</p>
	 	<p><button type="button" class="btn btn-info">注册信息</button></p>
		</form>
		
		
	</div>
	</div>
	<script type="text/javascript">
		$(function(){
			$("button").click(function(){
				
				//把form表单的数据序列化
				var formdata = $("form").serialize();
			
				$.ajax({
					type:"post",
					url:"RegisterServlet",
					data:formdata,
					dataType:"json",
					success:function(result){
						alert(result.message);//给出提示信息
						if(result.flag==true){
							var username = $("input").eq(0).val(); 
							alert(username);
							$.ajax({
								type:"post",
								url:"BalanceInsertServlet",
								data:"username="+username,
								dataType:"json",
								success:function(result2){
									if(result2.flag==true){
										location.href="login.jsp";
									}else{
										location.reload();
									}
								}
							});
							
						}else{
							location.reload();
						}
					}
				});
				
			});
			
		})
		
	
	
	</script>
</body>
</html>